<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #wangEditor,
      #text {
        width: 50%;
        float: left;
      }
      .wrap:after,
      .wrap:before {
        content: '';
        display: block;
        clear: both;
      }
    </style>
  </head>
  <body>
    <div class="wrap">
      <div id="wangEditor"></div>
      <div id="text"></div>
    </div>
    <button id="submitedit">提交</button>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <script
      type="text/javascript"
      src="https://unpkg.com/wangeditor/dist/wangEditor.min.js"
    ></script>
    <script type="text/javascript">
      const E = window.wangEditor
      const editor = new E('#wangEditor')
      // 或者 const editor = new E(document.getElementById('div1'))
      editor.config.uploadImgServer = '/uploadWang'
      //设置上传图片的header
      editor.config.uploadImgHeaders = {
        enctype: 'multipart/form-data',
      }
      editor.create()

      $('#submitedit').click(function () {
        alert(editor.txt.html())
        $('#text').html(editor.txt.html())
      })
    </script>
  </body>
</html>
